package com.sntk.organauthomanager.infrastructure.commit.impl;

import com.sntk.organauthomanager.application.dto.ResponseData;
import com.sntk.organauthomanager.infrastructure.commit.MedicalUserCommit;
import com.sntk.organauthomanager.infrastructure.utils.RestTemplateUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

/**
 * @ClassName: MedicalUserSingletonCommitImpl
 * @author: wgchao
 * @createTime: 2021/3/29 9:05 AM
 * @Description: TODO
 */
@Component
@ConditionalOnProperty(prefix = "env",name = "pattern",havingValue = "singleton")
public class MedicalUserSingletonCommitImpl implements MedicalUserCommit {

    @Value("${medical.url}")
    private String url;

    @Override
    public ResponseData searchAllocationUsers(String institutionNumber) {
        //TODO resttemplate 访问接口
//        Map<String, String> params = new HashMap<>();
//        params.put("institutionNumber", institutionNumber);
        String medicalUrl = url + "/sntk/pension/interior/user" + "?institutionNumber="+institutionNumber;
        ResponseEntity<ResponseData> responseEntity = RestTemplateUtil.get(medicalUrl, ResponseData.class);
        return responseEntity.getBody();
    }
}
